//Quelle Uhr: http://www.derlifestyleshop.de/images/product_images/popup_images/simpsons_wecker_homer_0199391.jpg

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace whereIsTheDonutGame
{

    public class InterruptScreen : Microsoft.Xna.Framework.DrawableGameComponent
    {
        donutGame game;

        SpriteFont font;
        SpriteBatch spriteBatch;

        Texture2D mainMenuPaused;

      KeyboardState kbState = Keyboard.GetState();    // aktueller Zustand der Tastatur
      KeyboardState oldkbState = Keyboard.GetState(); // Zustand der Tastatur im Frame davor
        int screenWidth, screenHeight;

        public bool gamefin = false;

        string statustext;
        string infotext;

        public InterruptScreen(donutGame game, int screenWidth, int screenHeight)
            : base(game)
        {
            this.game = game;
            this.screenHeight = screenHeight;
            this.screenWidth = screenWidth;
        }


        public override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            font = Game.Content.Load<SpriteFont>("Schriften/Andy");
            mainMenuPaused = game.Content.Load<Texture2D>("MainMenuPaused");
        }

        public override void Update(GameTime gameTime)
        {                           
            if (game.paused){
                statustext = "Paused";
                infotext = "Time left: " + game.timer.verbleibendeZeit + " Seconds\n" +
                    "Life's left: " + game.player.life;
               
            }

            if (game.player.life == 0){
                gamefin = true;
                statustext = "You're dead, sorry";
                infotext = "you have lost all your lives";
            }

            if (game.timer.zeitAbgelaufen == true){
                gamefin = true;
                statustext = "Time is over!";
                infotext = "you have been to slow!";
            }

            if ((game.spawn.numberOfDonuts - game.hud.counter) == 0
                    || (game.donuts2eat - game.hud.counter) == 0){
                gamefin = true;
                statustext = "Great, you did it!";
                infotext = "in only " + (game.timer.setzteSpieldauerInSek - game.timer.verbleibendeZeit) + " Seconds";
            }
            

            // um zu prüfen welchen Zustand Tastatur im Frame davor hatte
            oldkbState = Keyboard.GetState(); // oldkbState dem aktuelle Tastatur-Zustand zuweißen

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {

            if (game.paused)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(mainMenuPaused, new Vector2(0, 0), Color.White);
                //Große Überschrift:
                spriteBatch.DrawString(
                    font,                       //die Schriftart
                    statustext,                 //einfacher Text
                    new Vector2(150, 150),      //Position auf Bildschirm
                    Color.Red,                //Farbe 
                     -0.1f,                     //Rotation um eigenen Mittelpunkt
                    Vector2.Zero,               //Ursprung des Sprites
                    1.0f,                       //Scale
                    SpriteEffects.None,         //Effekte
                    1.0f                        //Tiefe der Ebene; 0 vorderste
                );

                //Unterer kleinerer Text
                spriteBatch.DrawString(
                    font,
                    infotext,
                    new Vector2(180, 300),
                    Color.White,
                     -0.1f,
                    Vector2.Zero,
                    0.5f,
                    SpriteEffects.None,
                    1.0f
                );

                spriteBatch.End();
            }
            else { }

        }



    }
}
